﻿using System;
using System.ServiceProcess;
using System.Windows.Forms;

namespace SBPweb.RouTorrent.Service
{
    public static class Program
    {

        public static MainService mainService;

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {

#if DEBUG

            Form1 mForm = new Form1();
            mForm.FormClosed += new FormClosedEventHandler(mForm_FormClosed);

            mainService = new MainService(args);
            mainService.Start();

            Application.Run(mForm);
            //do
            //{
            //    System.Threading.Thread.Sleep(1000);
            //}
            //while (true);

#else

            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[] 
			{ 
				mainService = new MainService(args) 
			};
            ServiceBase.Run(ServicesToRun);

#endif

        }

        static void mForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }
    }
}